package com.csd.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.csd.dao.BaseDao;
import com.csd.model.Store;
import com.csd.util.HttpHelper;

/**
 * Servlet implementation class StoreNameListServlet
 */
@WebServlet("/StoreNameListServlet")
public class StoreNameListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setCharacterEncoding("UTF-8");
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=utf-8");
		JSONObject obj = new JSONObject();
		int id = Integer.parseInt(request.getParameter("cid"));
		obj.put("cityID", id);
		obj.put("type", 0);
		String storeStr = HttpHelper.HttpPost(obj.toString(), BaseDao.STORES);
		PrintWriter out = response.getWriter();
		out.print(storeStr);
	}

}
